<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
  <title>get_all_ids_for_game (Batter)</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
  <pre><span class="ruby-comment cmt"># File lib/batter.rb, line 61</span>
  <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">get_all_ids_for_game</span>(<span class="ruby-identifier">gid</span>)
    <span class="ruby-identifier">batters_page</span> = <span class="ruby-constant">GamedayFetcher</span>.<span class="ruby-identifier">fetch_batters_page</span>(<span class="ruby-identifier">gid</span>)
    <span class="ruby-identifier">results</span> = []
    <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">batters_page</span>
      <span class="ruby-identifier">doc</span> = <span class="ruby-constant">Hpricot</span>(<span class="ruby-identifier">batters_page</span>)
      <span class="ruby-identifier">a</span> = <span class="ruby-identifier">doc</span>.<span class="ruby-identifier">at</span>(<span class="ruby-value str">'ul'</span>)  
      <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">a</span>
        (<span class="ruby-identifier">a</span><span class="ruby-operator">/</span><span class="ruby-value str">&quot;a&quot;</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">link</span><span class="ruby-operator">|</span>
          <span class="ruby-comment cmt"># look at each link inside of a ul tag</span>
          <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">link</span>.<span class="ruby-identifier">inner_html</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-value str">&quot;.xml&quot;</span>) <span class="ruby-operator">==</span> <span class="ruby-keyword kw">true</span>
            <span class="ruby-comment cmt"># if the link contains the text '.xml' then it is a batter</span>
            <span class="ruby-identifier">str</span> = <span class="ruby-identifier">link</span>.<span class="ruby-identifier">inner_html</span>
            <span class="ruby-identifier">str</span>.<span class="ruby-identifier">strip!</span>
            <span class="ruby-identifier">batter_id</span> = <span class="ruby-identifier">str</span>[<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-identifier">str</span>.<span class="ruby-identifier">length</span><span class="ruby-operator">-</span><span class="ruby-value">5</span>]
            <span class="ruby-identifier">results</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">batter_id</span>
          <span class="ruby-keyword kw">end</span>
        <span class="ruby-keyword kw">end</span>
      <span class="ruby-keyword kw">end</span>
    <span class="ruby-keyword kw">end</span>
    <span class="ruby-identifier">results</span>
  <span class="ruby-keyword kw">end</span></pre>
</body>
</html>